/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mbean.admin.problem;

import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import javax.ejb.EJB;
import model.entity.Problem;
import org.omnifaces.util.Faces;
import org.primefaces.model.LazyDataModel;
import service.InterfaceServiceLocal;
import utils.PageDateModel;

/**
 *
 * @author dingnangen
 */
@Named(value = "problemMB")
@SessionScoped
public class ProblemMB implements Serializable {

    @EJB(beanName = "ProblemManager")
    private InterfaceServiceLocal<Problem> problemManager;

    private LazyDataModel<Problem> items = null;

    private Problem currentProblem;

    /**
     * Creates a new instance of ProblemMB
     */
    public ProblemMB() {
    }

    /**
     * 初始化
     */
    public void init() {
        if (Faces.isPostback()) {
            System.out.println("isPostback");
            return;
        }
    }

    public LazyDataModel<Problem> getItems() {
        System.out.println("getItems");
        if (items == null) {
            System.out.println("getItems");
            items = new PageDateModel<Problem>("Problem", problemManager);

        }

        return items;
    }

    public void setItems(LazyDataModel<Problem> items) {
        this.items = items;
    }

}
